Skip to content

fix(@angular/cli): accept multi-digit array indices in ng config - #34305

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
thekhegay:fix/ng-config-multi-digit-index
Oct 12, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
thekhegay:fix/ng-config-multi-digit-index

Conversation

@thekhegay

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

parseJsonPath makes bracket segment number only when it is single digit (/^\d$/), so [10] stays string '10' and jsonc-parser cant find it in array
Option help shows a[3].foo.bar[2] as exmaple, nothing says indices stop at 9

Workspace with 12 styles:

ng config projects.app.architect.build.options.styles[9]          # s9.css
ng config projects.app.architect.build.options.styles[10]         # Value cannot be found.
ng config projects.app.architect.build.options.styles[10] x.css   # throws "Can not add index to parent of type array"

What is the new behavior?

Any run of digits is parsed as index, so styles[10] and a[2][13] work for get and set
Quoted segments like a['10'] stay string keys

parseJsonPath is exported now and new cli_spec.ts covers it, multi-digit case fails on main

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Unquoted [10] on object now acts like [3] always did, ["10"] still reaches such key

multi-digit index like `styles[10]` stayed string, so get failed and set threw
now any run of digits is parsed as array idnex

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request exports the parseJsonPath function and updates its regular expression to support multi-digit array indices, accompanied by new unit tests. The review feedback suggests a robust improvement to the quote-stripping logic to target only leading and trailing quotes, preventing unintended removal of internal quotes within keys.

Comment thread packages/angular/cli/src/commands/config/cli.ts

@alan-agius4 alan-agius4 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@alan-agius4 alan-agius4 added target: patch This PR is targeted for the next patch release action: merge The PR is ready for merge by the caretaker labels Oct 12, 2026
@alan-agius4
alan-agius4 merged commit 5c65615 into angular:main Oct 12, 2026
42 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator

This PR was merged into the repository. The changes were merged into the following branches:

@thekhegay
thekhegay deleted the fix/ng-config-multi-digit-index branch October 21, 2026 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/cli target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants